﻿<?php
header("Content-type:text/html; charset=utf-8");
include 'Config.php';

$pAttach = $_POST['pa_MP'];
$pMerBillNo = intval($_POST['p2_Order']);
$pAmount = number_format($_POST['p3_Amt'], 2, '.', '');


 //获取输入参数
$pVersion = 'v1.0.0';//版本号
$pMerCode=$pmercode;
$arrayMer=getMerInfo($pmercode);
$repJson=json_encode($arrayMer);
$repJson = json_decode($repJson);
$pMerName=$repJson->mername;
$pMerCert=$repJson->mercert;
$pAccount=$repJson->acccode;


$pBankCode = "";//银行代码
$pProductType= "";
$pIsCredit="";



$pGatewayType = "01";//支付方式 1个人网银 2企业
$pMerchanturl = "http://pay.hxxbc.cc/pay/ipsss/OrderReturn.php";
$pServerUrl = "http://pay.hxxbc.cc/pay/ipsss/OrderReturn.php";
$pMsgId = "msg".rand(1000,9999);//消息编号
$pReqDate = date("Ymdhis");//商户请求时间
$pDate = date("Ymd");//订单日期
$pCurrencyType = "GB";//币种

$pLang = "156";//语言
$pFailUrl = "";//支付结果失败返回的商户URL 
$pOrderEncodeTyp = "5";//订单支付接口加密方式 默认为5#md5
$pRetEncodeType = "17";//交易返回接口加密方式
$pRetType = "3";//返回方式 3=$pMerchanturl+$pServerUrl   2=$pMerchanturl
$pBillEXP = 1;//订单有效期(过期时间设置为1小时)
$pGoodsName = "userpay";//商品名称

 

 //请求报文的消息体
  $strbodyxml= "<body>"
	         ."<MerBillNo>".$pMerBillNo."</MerBillNo>"
	         ."<Amount>".$pAmount."</Amount>"
	         ."<Date>".$pDate."</Date>"
	         ."<CurrencyType>".$pCurrencyType."</CurrencyType>"
	         ."<GatewayType>".$pGatewayType."</GatewayType>"
                 ."<Lang>".$pLang."</Lang>"
	         ."<Merchanturl>".$pMerchanturl."</Merchanturl>"
	         ."<FailUrl>".$pFailUrl."</FailUrl>"
                 ."<Attach>".$pAttach."</Attach>"
                 ."<OrderEncodeType>".$pOrderEncodeTyp."</OrderEncodeType>"
                 ."<RetEncodeType>".$pRetEncodeType."</RetEncodeType>"
                 ."<RetType>".$pRetType."</RetType>"
                 ."<ServerUrl>".$pServerUrl."</ServerUrl>"
                 ."<BillEXP>".$pBillEXP."</BillEXP>"
                 ."<GoodsName>".$pGoodsName."</GoodsName>"
                 ."<IsCredit>".$pIsCredit."</IsCredit>"
                 ."<BankCode>".$pBankCode."</BankCode>"
                 ."<ProductType>".$pProductType."</ProductType>"
	      ."</body>";
  
  
 echo  $Sign=$strbodyxml.$pMerCode.$pMerCert;//签名明文

  
  $pSignature = md5($strbodyxml.$pMerCode.$pMerCert);//数字签名 
  //请求报文的消息头
  $strheaderxml= "<head>"
                   ."<Version>".$pVersion."</Version>"
                   ."<MerCode>".$pMerCode."</MerCode>"
                   ."<MerName>".$pMerName."</MerName>"
                   ."<Account>".$pAccount."</Account>"
                   ."<MsgId>".$pMsgId."</MsgId>"
                   ."<ReqDate>".$pReqDate."</ReqDate>"
                   ."<Signature>".$pSignature."</Signature>"
              ."</head>";
 
//提交给网关的报文
$strsubmitxml =  "<Ips>"
              ."<GateWayReq>"
              .$strheaderxml
              .$strbodyxml
	      ."</GateWayReq>"
            ."</Ips>";








include '../../config.php'; 
$time = date("Y-m-d H:i:s",time()+28800-date("Z",time()));
$conn = mysql_connect($dbhost,$conf['db']['user'],$conf['db']['password']);
if (!$conn)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db($dbname,$conn);
$Attach = mysql_escape_string($Attach);
$info = "INSERT INTO ssc_order(order_number, username, recharge_amount, state, time)
VALUES('".$pMerBillNo."', '".$pAttach."', '".$pAmount."', '0', '".$time."')";

mysql_query($info);
mysql_close($conn);






?>
<form name="form1" id="form1" method="post" action="http://newpay.ips.com.cn/psfp-entry/gateway/payment.html" target="_self">
<input type="hidden" name="pGateWayReq" value="<?php echo $strsubmitxml ?>" />
</form>
<script language="javascript">document.form1.submit();</script>